import { useEffect } from "react";
import { CategoryModelState, NavLink, useDispatch, useSelector } from "umi";
import styles from './index.less'
function category() {
    const { category } = useSelector((state: { category: CategoryModelState }) => state.category);
    const dispatch = useDispatch();
    console.log(category);
    
    useEffect(() => {
        dispatch({
            type: 'category/getCategory'
        })
    },[])
    return <div className={styles.scroll} >
        <li><NavLink to='/' exact activeStyle={{
                    fontWeight: 'bold',
                    color: '#ff0064',
                }}>所有</NavLink></li>
        {
            category ? category.map((item) => {
                return <li  key={item.id} ><NavLink to={`/category/${item.value}`} exact activeStyle={{
                    fontWeight: 'bold',
                    color: '#ff0064',
                }}>{item.label}</NavLink></li>
            }) : '暂无数据'
        }
    </div>
}
export default category